<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/10/22
 * Time: 11:09
 */
class RegionController extends Controller
{

    public function init()
    {
        parent::init();
        $__now_time = $_SERVER['REQUEST_TIME'];
        $this->_daytime = date("Y-m-d h:i:s", $__now_time);
        $this->_daydate = date("Y-m-d", $__now_time);
    }

    public function indexAction(){
        die();
    }

    public function getproviceAction(){
        if($this->_request->isPost()) {
            $Post = $this->_request->getPost();
            $Post['proviceid'] = empty($Post['proviceid']) ? 0 : (int)$Post['proviceid'];

            if (empty($Post['proviceid'])) {
                die("-1");
            }

            $region = new RegionModel();
            $ret = $region->getListByRow("region_pid", $Post['proviceid'],"region_pid desc");

            echo json_encode($ret);
            die();
        }
    }

    public function getareaAction(){
        if($this->_request->isPost()) {
            $Post = $this->_request->getPost();
            $Post['cityid'] = empty($Post['cityid']) ? 0 : (int)$Post['cityid'];

            if (empty($Post['cityid'])) {
                die("-1");
            }

            $region = new RegionModel();
            $ret = $region->getListByRow("region_pid", $Post['cityid'], "region_pid desc");

            echo json_encode($ret);
            die();
        }
    }


}